using System;
using System.Data;
using TimeSheetBLL.Brokers;

namespace TimeSheetBLL
{
	/// <summary>
	/// Summary description for BrokerFactory.
	/// </summary>
	public class BrokerFactory
	{
		
		public static Broker GetBroker( IDBEntity entity )
		{
			if( entity is ChargeableHours )
			{
				return new HoursBroker();
			}
			else if( entity is NonChargeableHours )
			{
				return new HoursBroker();
			}
			else if( entity is Client )
			{
				return new ClientBroker();
			}
			else if( entity is Project )
			{
				return new ProjectBroker();
			}
			else if( entity is Activity )
			{
				return new ActivityBroker();
			}
			else if( entity is User )
			{
				return new UserBroker();
			}
			else
			{
				return new Broker();
			}
		}

		public static long Save( IDBEntity entity )
		{
			IBroker broker = BrokerFactory.GetBroker( entity );
			return broker.Save( entity );
		}

		public static bool Delete( IDBEntity entity )
		{
			IBroker broker = BrokerFactory.GetBroker( entity );
			return broker.Delete( entity );
		}

		public static DataTable SelectAll( IDBEntity entity )
		{
			IBroker broker = BrokerFactory.GetBroker( entity );
			return broker.SelectAll( entity );
		}

		public static bool Fill( IDBEntity entity )
		{
			IBroker broker = BrokerFactory.GetBroker( entity );
			return broker.Fill( entity );
		}

	}//class
}//namespace
